package com.service.impl;

import com.dao.MenuDao;
import com.pojo.Menu;
import com.service.MenuService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class MenuServiceImpl implements MenuService {
    @Resource
    private MenuDao menuDao;

    public void setMenuDao(MenuDao menuDao) {
        this.menuDao = menuDao;
    }

    @Override
    @Transactional
    public void makeMenu() {
        menuDao.makeMenu();
        throw new RuntimeException();
    }

    @Override
    @Transactional
    public void getMenu(int mId, String mName) {
        menuDao.makeMenu();
        System.out.println("编号——————————————>" + mId + "——————————————>" + mName);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Menu> selectMenu() {
        return menuDao.selectMenu();
    }

    @Override
    @Transactional
    public int addMenu(Menu menu) {
        int i = menuDao.addMenu(menu);
        /*if (i > 0) {
            int num = 1;
            num = num / 0;
        }*/
        return i;
    }

    @Override
    public List<Menu> getMenuList() {
        return menuDao.selectMenu();
    }
}
